package com.ymatou.iapi.couponservice.service;

import org.json.JSONObject;

import com.ymatou.iapi.couponservice.parameter.CouponInfo;
import com.ymatou.iapi.couponservice.parameter.CouponInfos;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;

/**
 * 根据优惠券编号获取优惠券信息接口Call
 * FreeMaker Template自动生成代码
 */
public class GetCouponListByCodeCall extends YmatouBaseCall {
    private static String opurl = "api/Promotion/GetCouponListByCode";

    public GetCouponListByCodeCall() {
        super(EnvSetup.getSystemUrl("couponservice"), opurl, "POST", "JSON");
    }

    @Override
    public void addDefHeader() {
        client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
        client.addHeader("Content-Type", "application/json; charset=UTF-8");
    }

    public String getStatusCode1()
    {
        return getString("statusCode");
    }

    public String getMessage()
    {
        return getString("message");
    }

    public String getData()
    {
        return getString("data");
    }

    public CouponInfos getCouponInfos()
    {
        CouponInfos data = null;
        try {
            data = (CouponInfos) FormatUtil.GSONToObject(DataUtil.Json.parseJsonObj(getString("data")).toString(), CouponInfos.class);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return data;
    }
}
